import sklearn.datasets as datasets
from sklearn.cluster import KMeans
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

n_sample = 1500
random_state = 170
x,y=datasets.make_blobs(n_samples=n_sample,random_state=random_state)
# print(x.shape)
# print(y.shape)
# plt.scatter(x[:,0],x[:,1],c=y)
# plt.savefig("error.png")

y_new = KMeans(n_clusters=2).fit_predict(x)
plt.scatter(x[:,0],x[:,1],c=y_new)
plt.savefig('e2.png')

trans = [[-0.6,0.6],[-0.4,0.8]] #由于数据偏差，造成分类错误
x2=np.dot(x,trans)
plt